package JavaSE;
import java.util.Scanner;
//在同一个类中定义多个方法：要求不仅可以求2个整数的最大值，还可以求3个小数的最大值？
public class time_2027_07_04求最大值的方法重载 {
    public static double max(double num1,double num2){
        return num1>num2?num1:num2;
    }
    public static double max(double num1,double num2,double num3){
        return max(num1,num2)>num3? max(num1,num2):num3;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double result = 0.0;
        System.out.print("您要计算两个数的最大值还是三个数的最大值:（请输入2或3）");
        int input = scanner.nextInt();
        if(input==2){
            double num1 = scanner.nextDouble();
            double num2 = scanner.nextDouble();
            result = max(num1,num2);
        }if(input==3){
            double num1 = scanner.nextDouble();
            double num2 = scanner.nextDouble();
            double num3 = scanner.nextDouble();
            result = max(num1,num2,num3);
        }
        System.out.println("计算结果为:"+result);
    }
}
